package com.xyoto.community.controller;

import com.xyoto.community.dto.PageDTO;
import com.xyoto.community.dto.SearchUserDTO;
import com.xyoto.community.service.UserService;
import com.xyoto.community.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Author: 廖振辉
 * Date: 2021/11/24
 * Description: 用户广场controller
 */
@Api(tags = "用户广场")
@RequestMapping("/user")
@RestController
public class UserSquareController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户排行总榜(前20名)")
    @GetMapping("/getUserRankByHot")
    public Result getUserRankByHot(){
        return userService.getUserRankByHot();
    }

    @ApiOperation("获取我的总榜排名")
    @GetMapping("/getMyHotRank")
    public Result getMyHotRank(){
        return userService.getMyHotRank();
    }

    @ApiOperation("获取全部用户列表")
    @GetMapping("/getAllUserList")
    public Result getAllUserList(@Valid PageDTO pageDTO){
        return userService.getAllUserList(pageDTO);
    }

    @ApiOperation("根据用户名搜索用户")
    @GetMapping("/searchUser")
    public Result searchUser(@Valid SearchUserDTO searchUserDTO){
        return userService.searchUser(searchUserDTO);
    }

    @ApiOperation("获取用户总数")
    @GetMapping("/getTotalUserCount")
    public Result getTotalUserCount(){
        return userService.getTotalUserCount();
    }
}
